package openase.audiosearch.job.factory;

import java.nio.channels.SelectionKey;

import openase.audiosearch.job.CancellationJob;
import openase.audiosearch.job.ConnectionAcceptJob;
import openase.audiosearch.job.Job;
import openase.audiosearch.job.RequestJob;


public class JobFactory {

	private JobFactory() {
	}

	public static Job getJob(SelectionKey key) {
		if (!key.isValid()) {
			return new CancellationJob(key);
		}
		if (key.isAcceptable()) {
			return new ConnectionAcceptJob(key);
		}
		if (key.isReadable()) {
			return new RequestJob(key);
		}
		return null;// no Job for this kind of key
	}

}
